import { BasicColumn } from '/@/components/Table/src/types/table';
import { FormSchema } from '/@/components/Form';
import { useI18n } from '/@/hooks/web/useI18n';
import { getPartType } from '/@/api/demo/partManager';
import { FormProps } from '/@/components/Table';

const { t } = useI18n();
/**
 * 模块名:零件库表格
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/02/20 14:24:13
 */
export function getPartColumns(): BasicColumn[] {
  return [
    {
      title: t('routes.demo.partManagerSettings.code'),
      dataIndex: 'name',
      width: 200,
      slots: { customRender: 'name' },
      fixed: 'left',
      align: 'left',
    },
    {
      title: '缩略图',
      dataIndex: 'partUrl',
      align: 'center',
      width: 100,
      slots: { customRender: 'partUrl' },
    },
    {
      title: t('routes.demo.partManagerSettings.partName'),
      dataIndex: 'filename',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.status'),
      dataIndex: 'state',
      width: 150,
      slots: { customRender: 'state' },
    },
    {
      title: t('routes.demo.partManagerSettings.version'),
      dataIndex: 'version',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.type'),
      dataIndex: 'type',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.creator'),
      dataIndex: 'creator',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.createTime'),
      dataIndex: 'creattime',
      width: 150,
      slots: { customRender: 'creattime' },
    },
    {
      title: t('routes.demo.partManagerSettings.checkoutPerson'),
      dataIndex: 'checkOutPerson',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.customProp'),
      dataIndex: 'customize',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.DocOrPart'),
      dataIndex: 'fileorpart',
      width: 150,
      slots: { customRender: 'fileorpart' },
    },
    {
      title: t('routes.demo.partManagerSettings.isAssociatedFile'),
      dataIndex: 'isshortcut',
      width: 150,
      slots: { customRender: 'isshortcut' },
    },
    {
      title: t('routes.demo.partManagerSettings.Oid'),
      dataIndex: 'oId',
      width: 150,
    },
  ];
}

export function getCreatePartType(FolderId): FormSchema[] {
  return [
    {
      field: 'field1',
      component: 'ApiSelect',
      label: t('routes.demo.partManagerSettings.partType'),
      componentProps: {
        placeholder: t('routes.demo.partManagerSettings.partTypePlaceholder'),
        api: getPartType,
        params: FolderId.value,
        resultField: 'listPartType',
        labelField: 'value',
        valueField: 'label',
      },
    },
  ];
}

export function getPartDetailAttachmentColumns(): BasicColumn[] {
  return [
    {
      title: t('routes.demo.partManagerSettings.fileName'),
      dataIndex: 'fileName',
      fixed: 'left',
      align: 'left',
      width: 200,
    },
    {
      title: t('routes.demo.partManagerSettings.AttachmentType'),
      dataIndex: 'fileType',
      width: 100,
    },
  ];
}

export function getPartDetailCommonMapColumns(): BasicColumn[] {
  return [
    {
      title: t('routes.demo.partManagerSettings.fileName'),
      dataIndex: 'filename',
      fixed: 'left',
      align: 'left',
      width: 200,
    },
    {
      title: t('routes.demo.partManagerSettings.AttachmentType'),
      dataIndex: 'type',
      width: 100,
    },
  ];
}

export function getCreatePartAttachmentType(): FormSchema[] {
  return [
    {
      field: 'field1',
      component: 'ApiSelect',
      label: t('routes.demo.partManagerSettings.AttachmentType'),
      componentProps: {
        placeholder: t('routes.demo.partManagerSettings.AttachmentTypePlaceholder'),
        // api: getPartFeature,
        // resultField: 'partList',
        // labelField: 'value',
        // valueField: 'label',
      },
    },
    {
      field: 'field2',
      component: 'Upload',
      label: t('routes.demo.partManagerSettings.UploadFile'),
    },
  ];
}

export function getPartAssociatedColumns(): BasicColumn[] {
  return [
    {
      title: t('routes.demo.partManagerSettings.figureDocCode'),
      dataIndex: 'thitObjectId',
      fixed: 'left',
      align: 'left',
      width: 200,
    },
    {
      title: t('routes.demo.partManagerSettings.version'),
      dataIndex: 'version',
      width: 100,
    },
    {
      title: t('routes.demo.partManagerSettings.figureDocName'),
      dataIndex: 'fileName',
      width: 100,
    },
    {
      title: t('routes.demo.partManagerSettings.figureDocType'),
      dataIndex: 'fileType',
      width: 100,
    },
    {
      title: t('routes.demo.partManagerSettings.creator'),
      dataIndex: 'creater',
      width: 150,
    },
    {
      title: 'id',
      dataIndex: 'id',
      width: 150,
      ifShow: false,
    },
  ];
}

export function getPartContrastColumns(): BasicColumn[] {
  return [
    {
      title: t('routes.demo.partManagerSettings.partCode'),
      dataIndex: 'partCode',
      fixed: 'left',
      align: 'left',
      width: 200,
    },
    {
      title: t('routes.demo.partManagerSettings.partVersion'),
      dataIndex: 'partVersion',
      width: 100,
    },
    {
      title: t('routes.demo.partManagerSettings.add'),
      dataIndex: 'add',
      width: 100,
    },
    {
      title: t('routes.demo.partManagerSettings.delete'),
      dataIndex: 'delete',
      width: 100,
    },
    {
      title: t('routes.demo.partManagerSettings.originalNumber'),
      dataIndex: 'originalNumber',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.currentNumber'),
      dataIndex: 'currentNumber',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.parentCode'),
      dataIndex: 'parentCode',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.parentVersion'),
      dataIndex: 'parentVersion',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.partName'),
      dataIndex: 'partName',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.remark'),
      dataIndex: 'remark',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.quantity'),
      dataIndex: 'quantity',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.base'),
      dataIndex: 'base',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.lossRate'),
      dataIndex: 'lossRate',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.status'),
      dataIndex: 'status',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.checkoutPerson2'),
      dataIndex: 'checkoutPerson2',
      width: 150,
    },
  ];
}

export function workHandOver(): FormSchema[] {
  return [
    {
      field: 'holderName',
      component: 'Input',
      label: t('routes.demo.documentManager.admitter'),
      colProps: {
        xl: 12,
        xxl: 12,
      },
      componentProps: {
        disabled: true,
      },
    },
    {
      label: t('routes.demo.documentManager.receiver'),
      field: 'receiver',
      slot: 'receiver',
      component: 'Input',
      colProps: {
        xl: 12,
        xxl: 12,
      },
    },
    {
      field: 'name',
      component: 'Input',
      label: t('routes.demo.documentManager.objectCode'),
      colProps: {
        xl: 12,
        xxl: 12,
      },
      componentProps: {
        disabled: true,
      },
    },
    {
      field: 'version',
      component: 'Input',
      label: t('routes.demo.documentManager.objectVersion'),
      colProps: {
        xl: 12,
        xxl: 12,
      },
      componentProps: {
        disabled: true,
      },
    },
    {
      field: 'BOM',
      component: 'Checkbox',
      label: t('routes.demo.documentManager.bom'),
      colProps: {
        xl: 12,
        xxl: 12,
      },
    },
  ];
}

export function getFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 100,
    colon: false, // 是否显示冒号
    showActionButtonGroup: false, // 是否显示操作按钮
    schemas: [
      {
        field: `selectTime`,
        label: t('routes.demo.partManager.specifiedTime'),
        component: 'DatePicker',
        colProps: {
          xl: 12,
          xxl: 8,
        },
        componentProps: {
          placeholder: t('routes.demo.partManager.specifiedTimePlaceholder'),
        },
      },
    ],
  };
}

export function getUseFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 100,
    colon: false, // 是否显示冒号
    schemas: [
      {
        field: `partCode`,
        label: t('routes.demo.partManager.useSituationPage.partCode'),
        component: 'Input',
        colProps: {
          xl: 12,
          xxl: 8,
        },
        componentProps: {
          placeholder: t('routes.demo.partManager.useSituationPage.partCodePlaceholder'),
        },
      },
      {
        field: `subPartCode`,
        label: t('routes.demo.partManager.useSituationPage.subPartCode'),
        component: 'Input',
        colProps: {
          xl: 12,
          xxl: 8,
        },
        componentProps: {
          placeholder: t('routes.demo.partManager.useSituationPage.subPartCodePlaceholder'),
        },
      },
      {
        field: `queryType`,
        label: t('routes.demo.partManager.useSituationPage.queryType'),
        component: 'RadioGroup',
        defaultValue: '1',
        colProps: {
          xl: 12,
          xxl: 8,
        },
        componentProps: {
          options: [
            {
              label: t('routes.demo.partManager.useSituationPage.singleLevel'),
              value: '1',
            },
            {
              label: t('routes.demo.partManager.useSituationPage.multiLevel'),
              value: '2',
            },
            {
              label: t('routes.demo.partManager.useSituationPage.singleLevelHistory'),
              value: '3',
            },
            {
              label: t('routes.demo.partManager.useSituationPage.multiLevelHistory'),
              value: '4',
            },
          ],
        },
      },
    ],
  };
}

export function getProductionDesignColumns(): BasicColumn[] {
  return [
    {
      title: t('routes.demo.partManagerSettings.code'),
      dataIndex: 'name',
      width: 150,
      slots: { customRender: 'name' },
    },
    {
      title: t('routes.demo.partManagerSettings.version'),
      dataIndex: 'version',
      width: 150,
    },
    {
      title: t('routes.demo.partManagerSettings.type'),
      dataIndex: 'type',
      width: 150,
    },
  ];
}

export function getProductionDesignConfig(): Partial<FormProps> {
  return {
    labelWidth: 100,
    colon: false, // 是否显示冒号
    schemas: [
      {
        field: `name`,
        label: t('routes.demo.partManagerSettings.code'),
        component: 'Input',
        colProps: {
          xl: 12,
          xxl: 12,
        },
        componentProps: {
          placeholder: '请输入代号',
        },
      },
    ],
  };
}

export function checkoutSchemas(): FormSchema[] {
  return [
    {
      field: 'createNewVersion',
      label: '是否创建新版本',
      component: 'RadioButtonGroup',
      defaultValue: '0',
      componentProps: {
        options: [
          { label: t('common.no'), value: '0' },
          { label: t('common.yes'), value: '1' },
        ],
      },
      colProps: { lg: 24, md: 24 },
    },
    {
      field: 'sendMessage',
      label: '是否发送消息',
      component: 'RadioButtonGroup',
      defaultValue: '0',
      componentProps: {
        options: [
          { label: t('common.no'), value: '0' },
          { label: t('common.yes'), value: '1' },
        ],
      },
      colProps: { lg: 24, md: 24 },
    },
  ];
}
